package com.sqlcheck.dto.request;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.util.List;

@Data
@Schema(description = "数据库DDL提取请求")
public class DatabaseDdlExtractionRequest {

    @NotBlank(message = "数据库主机不能为空")
    @Schema(description = "数据库主机地址", example = "localhost", required = true)
    private String host;

    @NotNull(message = "数据库端口不能为空")
    @Schema(description = "数据库端口", example = "3306", required = true)
    private Integer port;

    @NotBlank(message = "数据库名称不能为空")
    @Schema(description = "数据库名称", example = "test_db", required = true)
    private String database;

    @Schema(description = "数据库Schema名称", example = "public")
    private String schema;

    @NotBlank(message = "数据库用户名不能为空")
    @Schema(description = "数据库用户名", example = "db_user", required = true)
    private String username;

    @NotBlank(message = "数据库密码不能为空")
    @Schema(description = "数据库密码", example = "db_password", required = true)
    private String password;

    @NotBlank(message = "数据库类型不能为空")
    @Schema(description = "数据库类型", example = "MYSQL", required = true, allowableValues = {"MYSQL", "ORACLE"})
    private String dbType;

    @Schema(description = "数据库版本", example = "8.0")
    private String dbVersion;

    @Schema(description = "DDL提取选项")
    private DdlExtractionOptions options;

    @Data
    @Schema(description = "DDL提取选项")
    public static class DdlExtractionOptions {
        @Schema(description = "是否包含视图", example = "true")
        private Boolean includeViews = true;

        @Schema(description = "是否包含索引", example = "true")
        private Boolean includeIndexes = true;

        @Schema(description = "是否包含约束", example = "true")
        private Boolean includeConstraints = true;

        @Schema(description = "目标表名列表（为空则提取所有表）")
        private List<String> targetTables;

        @Schema(description = "是否包含存储过程", example = "false")
        private Boolean includeProcedures = false;

        @Schema(description = "是否包含函数", example = "false")
        private Boolean includeFunctions = false;

        @Schema(description = "是否包含触发器", example = "false")
        private Boolean includeTriggers = false;
    }
}